// 引入接口模块
import request from '@/utils/request'

// 分页查询课程信息
export const getQueryCourses = data => {
  return request({
    method: 'post',
    url: '/boss/course/getQueryCourses',
    data
  })
}

// 课程上下架
export const changeState = data => {
  return request({
    method: 'get',
    url: '/boss/course/changeState',
    params: {
      courseId: data.courseId,
      status: data.status
    }
  })
}

// 上传图片接口，接受第二个参数一个函数
export const upLoad = (data, onUploadProgress) => {
  return request({
    method: 'post',
    url: '/boss/course/upload',
    data,
    // onUploadProgress是H5提供的用于检测上传进度的方法
    onUploadProgress
  })
}

// 保存或者更新课程信息
export const saveOrUpdateCourse = data => {
  return request({
    method: 'post',
    url: '/boss/course/saveOrUpdateCourse',
    data
  })
}

// 根据课程id查询课程信息
export const getCourseById = courseId => {
  return request({
    method: 'get',
    url: `/boss/course/getCourseById?courseId=${courseId}`
  })
}

// 获取课程全部章节内容
export const getSectionAndLesson = courseId => {
  return request({
    method: 'get',
    url: `/boss/course/section/getSectionAndLesson?courseId=${courseId}`
  })
}

// 保存或者更新章节
export const saveOrUpdateSection = data => {
  return request({
    method: 'post',
    url: '/boss/course/section/saveOrUpdateSection',
    data
  })
}

// 保存或者更新课时
export const saveOrUpdate = data => {
  return request({
    method: 'post',
    url: '/boss/course/lesson/saveOrUpdate',
    data
  })
}
